package com.example.demo.dao;


import com.example.demo.entity.Collect;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author liuxianchun
 * @date 2021/1/22
 */
@Repository
public interface CollectDao {

    @Insert("insert into collect(userId,productId,collectTime) values(#{userId},#{productId},now())")
    void addCollect(int userId,int productId);

    @Select("select * from collect where userId=#{userId}")
    List<Collect> getCollect(int userId);

    @Select("select count(1) from collect where userId=#{userId} and productId=#{productId}")
    int findCollect(int userId,int productId);

    @Delete("delete from collect where userId=#{userId} and productId=#{productId}")
    void deleteCollect(int userId, int productId);

}
